home *** CD-ROM | disk | FTP | other *** search
- ; cml.a - convert memory line.
- ; (C) Copyright 1985 Cray Research Inc. - All Rights Reserved.
- ; G. R. Mansfield. 85/06/18.
- ; Ver 1.0-5828.
-
-
- cseg
- public cml_
-
-
- ; cml(s, a, d) /* convert memory line */
- ; BYTE *a, *d;
- ; char *s;
-
- cml_: mov bx,sp
- mov di,[bx+2] ; destination string
- mov si,[bx+4] ; memory address
- mov ax,[bx+6] ; convert address
- call chw
-
- ; convert hexadecimal data.
-
- mov cx,16
- cml1: mov al,' ' ; space to separate bytes
- stosb
- test cl,3 ; check conversion
- jnz cml2 ; if not 4 bytes
- stosb ; add space
- cml2: lodsb ; convert byte
- call chb
- loop cml1 ; loop for 16 bytes
-
- ; add ASCII characters.
-
- mov al,' ' ; space to separate fields
- stosb
- stosb
- mov cx,16
- sub si,cx
- cml3: lodsb ; next byte
- cmp al,020h ; change non-displayable to '.'
- jb cml4
- cmp al,07Fh
- jbe cml5
- cml4: mov al,'.'
- cml5: stosb
- loop cml3 ; loop for 16 bytes
-
- mov al,0 ; end line
- stosb
- ret
-
-
- ; chw - Convert hexadecimal word.
- ; entry ax = word.
-
- chw: push ax ; upper byte
- xchg al,ah
- call chb
- pop ax ; lower byte
- ; jmp chb
-
-
- ; chb - Convert hexadecimal byte.
- ; entry al = byte.
-
- chb: push ax ; upper digit
- shr al,1
- shr al,1
- shr al,1
- shr al,1
- add al,090h ; 10 - 15 to 'A' - 'F'
- daa
- adc al,040h ; 0 - 9 to '0' - '9'
- daa
- stosb
- pop ax ; lower digit
- and al,00Fh
- add al,090h ; 10 - 15 to 'A' - 'F'
- daa
- adc al,040h ; 0 - 9 to '0' - '9'
- daa
- stosb
- ret
-